package com.flong.desgin.patterns.interfacesegregationprinciple;

/**
 * 接口隔离设计
 */
public class InterfaceSegregationPrinciple1 {

    public static void main(String[] args) {

    }

}

/**
 * 接口
 */
interface Interface1 {
    void operation1();

    void operation2();

    void operation3();

    void operation4();

    void operation5();
}

class A implements Interface1 {
    @Override
    public void operation1() {
        System.out.println("A实现1");
    }
    @Override
    public void operation2() {
        System.out.println("A实现2");
    }
    @Override
    public void operation3() {
        System.out.println("A实现3");
    }

    @Override
    public void operation4() {
        System.out.println("A实现4");
    }
    @Override
    public void operation5() {
        System.out.println("A实现5");
    }
}


class B implements Interface1 {
    @Override
    public void operation1() {
        System.out.println("B实现1");
    }
    @Override
    public void operation2() {
        System.out.println("B实现2");
    }
    @Override
    public void operation3() {
        System.out.println("B实现3");
    }

    @Override
    public void operation4() {
        System.out.println("B实现4");
    }
    @Override
    public void operation5() {
        System.out.println("C实现5");
    }
}

/**
 * C只是依赖Interface的operation1、operation2、operation3
 */
class C {

    public void depend1(Interface1 interface1) {
        interface1.operation1();
    }

    public void depend2(Interface1 interface1) {
        interface1.operation2();
    }

    public void depend3(Interface1 interface1) {
        interface1.operation3();
    }

}

/**
 * D只是依赖Interface的operation4、operation5
 */
class D {


    public void depend4(Interface1 interface1) {
        interface1.operation4();
    }

    public void depend5(Interface1 interface1) {
        interface1.operation5();
    }

}